/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.edu.cs576.HyperLinkVideo.authoringtool;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;

/**
 *
 * @author Ludo
 */
public class CustomMenuItem extends JMenuItem{
    private int index;
    private SecondaryVideoViewPanel panel;
    private AuthoringToolGUI tool;
    
    public CustomMenuItem(int index, SecondaryVideoViewPanel panel, AuthoringToolGUI tool){
        super();
        this.index = index;
        this.panel = panel;
        this.tool = tool;
        this.addActionListener(new CustomActionListener(this));
    }
    
    public void setVideo(){
        if(panel!= null){
            panel.setVideo(index);
            tool.resetScrollBar();
            panel.repaint();
        }
    }
    
    public void setIndex(int index){
        this.index = index;
    }
    
    public int getIndex(){
        return index;
    }
    
    public class CustomActionListener implements ActionListener{
        CustomMenuItem menuItem;
        
        public CustomActionListener(CustomMenuItem menuItem){
            super();
            this.menuItem = menuItem;
        }
        
        @Override
        public void actionPerformed(ActionEvent e) {
            menuItem.setVideo();
        }
        
    }

}
